Skip to content

Lend a small export its RAW's detail above the photograph's samples - #3

Merged
oddharsh merged 2 commits into
mainfrom
raw-guided-detail
Nov 2, 2026
Merged

oddharsh merged 2 commits into
mainfrom
raw-guided-detail

Conversation

@oddharsh

@oddharsh oddharsh commented Nov 1, 2026

Copy link
Copy Markdown
Owner

When a photograph has to be enlarged to the delivery width and a RAW with the same stem sits beside it (or in a --raw folder), ig-prep now borrows the RAW's detail above what the photograph samples. A full-size camera file never decodes its RAW, so its output is byte-identical to main.

How the merge works

The photograph stays the authority on the look:

  • It's enlarged whole with Lanczos over a fractional window.
  • The RAW is resized to the output and mapped onto the photograph's colour with a 20-term cubic, fitted on the photograph's own samples.
  • Only the RAW's band above the photograph's Nyquist is added: mapped - LP(mapped), where LP goes down to the photograph's size and back up.
  • That band is scaled per 64px tile by a least-squares gain, measuring how well the RAW's next octave down agrees with the photograph's own top octave. The gain is clamped to [0, 1], so detail the photograph doesn't share (noise, a different render) is held back.
  • The result is clamped to the photograph's local min/max, which stopped the highlight specks the cubic used to extrapolate on Eterna.

ig-prep refuses a RAW whose capture time, frame shape (0.3% slack) or high-pass structure (NCC under 0.5) disagrees with the photograph's. --no-raw turns the search off. The MCP server takes raw and raw_dirs, both kept under --root.

Measured

Five X-T50 frames, exported at 2048 and rebuilt at 3072, were scored against each HIF's own 3072 output. Scores are SSIMULACRA2 / Butteraugli max norm, from fast-ssim2 0.9.0 and butteraugli 0.9.3. The run was on 2026-11-01.

Frame Film sim Enlarged With the RAW
XT500078 Nostalgic Neg 74.9 / 4.33 77.6 / 3.15
XT500947 Nostalgic Neg 76.1 / 2.64 76.4 / 2.55
XT500955 Classic Chrome 83.5 / 3.17 83.5 / 2.36
XT501070 Provia 66.7 / 4.34 75.9 / 4.82
XT501004 Eterna 80.6 / 3.47 79.5 / 4.34

Known limit: Eterna still loses on both metrics. The RAW engine renders glitter as different sparkles than the camera does, and the tile gain only partly holds them back. Provia's Butteraugli also rises (4.34 to 4.82) while SSIMULACRA2 gains 9.2. A merged 2048 export takes 9.8s.

Checks

  • cargo test --release --locked: 77 passed. 8 of them are new, in src/raw.rs. One adds white noise to the RAW and asserts the merge moves the output under a fifth of the RAW's own distance: 3.62 levels against 24.87. With the gate removed it moves 12.59 and fails.
  • cargo fmt --check and cargo clippy --all-targets -- -D warnings: clean.
  • Full-size HIFs (XT501004, XT501070) produce byte-identical output with and without their RAWs present.

When a photograph is enlarged to the delivery width and a RAW with the same
stem sits beside it or in a --raw folder, the RAW adds detail above what the
photograph samples. The photograph stays the authority on the look: it is
enlarged whole, the RAW is mapped onto its colour with a cubic, and only the
RAW's band above the photograph's Nyquist is added, scaled per 64px tile by
how well the RAW's next octave down agrees with the photograph's, and held
inside the photograph's local range.

A RAW is refused when its capture time, frame shape or fine structure
disagrees with the photograph's. A full-size camera file never decodes its
RAW, so its output is byte-identical. --no-raw turns the search off; the MCP
server takes raw and raw_dirs, kept under --root.

Measured 2026-11-01 on five X-T50 frames exported at 2048 and rebuilt at
3072, scored against each HIF's own 3072 output with fast-ssim2 0.9.0 and
butteraugli 0.9.3 (SSIMULACRA2 / Butteraugli max norm): Nostalgic Neg
74.9/4.33 -> 77.6/3.15 and 76.1/2.64 -> 76.4/2.55, Classic Chrome
83.5/3.17 -> 83.5/2.36, Provia 66.7/4.34 -> 75.9/4.82, and Eterna
80.6/3.47 -> 79.5/4.34, where the RAW engine renders glitter as different
sparkles.
CI's stable toolchain moved to 1.99, whose new lint rejects chunks_exact
with a constant size. as_chunks has been stable since 1.88, under the
crate's rust-version of 1.93. simulate.rs on main trips the same lint.
@oddharsh
oddharsh merged commit cda7d95 into main Nov 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant